package com.key.utils;

import com.key.entity.*;
import com.key.mapper.ShowBackMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
/*
*
 * @description:数据回显工具类
 * @author: jianjiawei
 * @date: 2023/2/20 9:47
 **/
@Component
public class ShowBackUtils {

    @Autowired
    private ShowBackMapper showMapper;

    /*
    *
     * @description:获取全部类别
     * @author: jianjiawei
     * @date: 2023/2/20 10:20
     **/
    public List<String> showAssetTypes(){
        List<AssetType> assetTypes = showMapper.showAssetTypes();
        System.out.println(assetTypes);
        List<String> types = new ArrayList<>();
        for (AssetType assetType : assetTypes) {
            types.add(assetType.getAssetTypeName());
        }
        return types;
    }

    /*
    *
     * @description:查询所有公司
     * @author: jianjiawei
     * @date: 2023/2/20 10:36
     **/
    public List<String> showCompanies(){
        List<Company> companies = showMapper.showCompanies();
        List<String> companys = new ArrayList<>();
        for (Company company : companies) {
            companys.add(company.getCompanyName());
        }
        return companys;
    }

    /*
    *
     * @description:查询所有型号
     * @author: jianjiawei
     * @date: 2023/2/20 10:37
     **/
    public List<String> showAssetModels(){
        List<AssetModel> assetModels = showMapper.showAssetModels();
        List<String> models = new ArrayList<>();
        for (AssetModel assetModel : assetModels) {
            models.add(assetModel.getModelName());
        }
        return models;
    }

    /*
    *
     * @description:查询所有使用人
     * @author: jianjiawei
     * @date: 2023/2/20 10:39
     **/
    public List<String> showUsers(){
        List<Employee> employees = showMapper.showUsers();
        List<String> users = new ArrayList<>();
        for (Employee employee : employees) {
            users.add(employee.getEmployeeName());
        }
        return users;
    }

    /*
    *
     * @description:查询所有区域
     * @author: jianjiawei
     * @date: 2023/2/24 15:38
     **/
    public List<String> showRegions(){
        List<CArea> cAreas = showMapper.showRegions();
        List<String> regions = new ArrayList<>();
        for (CArea cArea : cAreas) {
            regions.add(cArea.getCAreaName());
        }
        return regions;
    }

    /*
    *
     * @description:查询所有部门
     * @author: jianjiawei
     * @date: 2023/2/24 15:52
     **/
    public List<String > showDepartments(){
        List<Department> departments = showMapper.showDepartments();
        List<String> depts = new ArrayList<>();
        for (Department department : departments) {
            depts.add(department.getDepartmentName());
        }
        return depts;
    }

}
